//获取按钮

const buts:Element[] | null = Array.from(document.querySelectorAll('button'))

//背景颜色的枚举
enum Color{
    'green',
    'yellow',
    'skyblue',
    'red'
}


//添加点击事件
buts.forEach((item ,itx)=> {
    item.addEventListener('click',(e)=>{
        // console.log(e);
        //创建弹框
        const dialogDom = document.createElement('div')

        const text:any = item.getAttribute('text');

        (dialogDom.innerHTML as string) = text

        //dialogDom添加类名
        dialogDom.className = "dialogBox";

        dialogDom.style.background = Color[itx]

        document.body.appendChild(dialogDom);

        setTimeout(()=>{
            const dom:Element | null = document.querySelector('.dialogBox')

            dom?.remove()
        },3000)
        
    })
})